<template>
    <poup :cancelText="cancelText" :confirmText="confirmText" ref="poup" @confirm="confirm">
        <pic :slots="slots" @change="onChange" :visibleItemCount="visibleItemCount"></pic>
    </poup>
</template>
<script>
import pic from '@/components/picker/picker.vue';
import poup from './poup.vue';
export default {
    name: 'data-picker',
    components: { pic, poup },
    props: {
        cancelText: {
            type: String,
            default: '取消'
        },
        confirmText: {
            type: String,
            default: '确定'
        },
        visibleItemCount: {
            type: Number,
            default: 5
        },
        slots: {
            type: Array
        }
    },
    methods: {
        open () {
            this.$refs.poup.open();
        },
        close () {
            this.$refs.poup.close();
        },
        onChange (picker, data) {
            this.$emit('change', picker, data);
        },
        confirm () {
            this.$emit('confirm', this.currentValue);
        }
    }
};
</script>
